<?php 

class Admin_Model_Users {
	
	protected $data;
	
	protected $_SessionNamespace;
	
	public function __construct(){
		$this->init();
	}
	
	public function init()
    {	
    	$this->loadSessionNamespace();
    }
    
    public function setSessionNamespace(Zend_Session_Namespace $namespace)
	{
		$this->_SessionNamespace = $namespace;
	}
	
	public function getSessionNamespace()
	{
		if(is_null($this->_SessionNamespace)){
			$this->setSessionNamespace(new Zend_Session_Namespace(__CLASS__));
		}
		return($this->_SessionNamespace);
	}
	
	public function persist()
	{
		$this->getSessionNamespace()->data = $this->data;
	}
	
	public function loadSessionNamespace()
	{
		if (isset($this->getSessionNamespace()->data)) {
            $this->data = $this->getSessionNamespace()->data;
        }
	}
	
	public function addData($data){
		$this->data = new stdClass();
		foreach($data as $key => $value)
			$this->data->$key = $value;
		$this->persist();
	}
    
	public function getData(){
		$this->loadSessionNamespace();
		return $this->data;
	}
}